import { defineConfig } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'

// https://vitejs.dev/config/
export default defineConfig({
  build: {
    // 开发阶段启用源码映射：https://uniapp.dcloud.net.cn/tutorial/migration-to-vue3.html#需主动开启-sourcemap
    sourcemap: process.env.NODE_ENV === 'development',
  },
  plugins: [uni()],
  base: './',
  server: {
    cors: true, // 默认启用并允许任何源
    open: true, // vite项目启动时自动打开浏览器
    host: '0.0.0.0', //设置为0.0.0.0则所有的地址均能访问
    port: 8085,
    proxy: {
      '/api': {
        target: 'https://api.xxx.com', // 目标服务
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ''),
      },
    },
  },
})
